package com.b2c.repository.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 描述：
 * 订单号生成工具
 *
 * @author qlp
 * @date 2018-12-19 11:27 AM
 */
public class OrderNumberUtils {
    /**
     * 生成订单好
     *
     * @return
     */
    public static String getOrderIdByTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
        String newDate = sdf.format(new Date());
        String result = "";
        Random random = new Random();
        for (int i = 0; i < 3; i++) {
            result += random.nextInt(10);
        }
        return newDate + result;
    }

    public static String getOrderIdByMinute() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmm");
        String newDate = sdf.format(new Date());
//        String result = "";
//        Random random = new Random();
//        for (int i = 0; i < 3; i++) {
//            result += random.nextInt(10);
//        }
        return newDate;
    }

}
